Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop parenthesizing context managers on Python 3.9 #4488

Closed
wants to merge 5 commits into from

Conversation

A5rocks
Copy link

@A5rocks A5rocks commented Oct 16, 2024

Description

Discovered in python-trio/trio#3106 (comment), black is parenthesizing context managers for Python 3.9 despite that only officially landing in 3.10.

This isn't actually much of an issue as CPython 3.9 allows it and I assume PyPy does too, but it could technically be an issue and does mess things up with -X oldparser on 3.9.

Checklist - did you ...

  • Add an entry in CHANGES.md if necessary?
  • Add / update tests if necessary?
  • Add new / update outdated documentation?

@JelleZijlstra
Copy link
Collaborator

This feels not worth it. We'd cause churn on projects that already run on 3.9 only. I'd rather stick with the new syntax only at this point.

@A5rocks
Copy link
Author

A5rocks commented Oct 16, 2024

This feels not worth it. We'd cause churn on projects that already run on 3.9 only. I'd rather stick with the new syntax only at this point.

Makes sense. The way it's implemented it doesn't actually downgrade already parenthesized context managers, if I remember correctly. Though that's obviously a bug that could maybe be treated as a feature.

src/black/mode.py Outdated Show resolved Hide resolved
@JelleZijlstra
Copy link
Collaborator

Thanks, but I'm going to reject this, especially since we've already released this style for a long time. Parenthesized context managers realistically work fine in Python 3.9; it's unlikely that anybody is actively using -X oldparser.

@A5rocks A5rocks deleted the no-parens-for-cms-39 branch October 17, 2024 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants